expand: Add error check if derive has wrong item#4359
expand: Add error check if derive has wrong item#4359Pasta-coder wants to merge 1 commit intoRust-GCC:masterfrom
Conversation
786575e to
57ad8d3
Compare
|
Hello, thanks for your contribution! Small nitpick on the Changelog part... Does not target a specific "item". You could be more precise using: |
ff0806a to
9e84d88
Compare
|
@dkm hello, commit message regarding changelog changed . thanks |
11bd185 to
475edf5
Compare
|
I realized there might be a potential false positive with If I am going to verify this locally by adding a test case for a tuple struct. If it fails, I will update |
Thanks! |
9cee832 to
eb4177c
Compare
|
@dkm hello, I reverted the extra Kind check since Open for review . thankyou |
|
@P-E-P please review . thankyou . |
|
@CohenArthur please review . thankyou . |
P-E-P
left a comment
There was a problem hiding this comment.
I don't really get what this PR brings on the table. Sure there is a new fancy helper function, but it has a side effect, we're emitting an error. Moving the error out of that helper means it becomes so short a function may not even be worth it anymore.
The check was already there so we didn't get anything from that.
We do get a new test which is a bit more complete compared to rust/compile/issue-3971.rs.
Am I missing something ?
|
introducing helper function does have a side effect . why i did what i did ? the ICE was solved in #4211 but issue #3875 was still open with comments suggesting a helper function , also test was missing
thankyou |
I think we should definitely keep the test, but I wouldn't keep the rest of the changes. |
f4ee91d to
207332f
Compare
|
@P-E-P now this pr only adds the test . thankyou. |
a3e1065 to
ea8c59e
Compare
c775b26 to
721a7fc
Compare
This patch adds a regression test ensuring that deriving on invalid items (such as functions or traits) triggers a diagnostic error instead of an Internal Compiler Error (ICE). It also verifies that Tuple Structs are accepted as valid targets for derivation. Fixes Rust-GCC#3875 gcc/testsuite/ChangeLog: * rust/compile/issue-3875.rs: New test. Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
721a7fc to
41639b7
Compare
|
@P-E-P this can also be merged . review once , thanks . edit - didn't see you self requested a review . |
|
@P-E-P this pr is getting stale , any chance of merging it ? |
The DeriveVisitor previously dispatched calls to specific handlers (like DeriveClone) without validating the input item type. This caused internal compiler errors (ICEs) when users attempted to derive traits on invalid items like functions or traits, as the handlers assumed the input was a struct, enum, or union.
This patch adds a validation predicate to the DeriveVisitor to reject invalid items gracefully with a diagnostic error before dispatching.
Fixes #3875
gcc/rust/ChangeLog:
gcc/testsuite/ChangeLog:
make check-rustpasses locallyclang-formatgcc/testsuite/rust/